package com.lyl.example.common.exception;


import com.lyl.example.common.result.ResultCode;
import lombok.Data;
import lombok.EqualsAndHashCode;

/**
 * @author Mr.Luo
 * @desc 业务异常
 */
@EqualsAndHashCode(callSuper = true)
@Data
public class BizException extends RuntimeException {

    private final ResultCode res;

    private final String errorMsg;

    public BizException(String errorMsg) {
        super(errorMsg);
        this.res = ResultCode.BUSINESS_ERROR;
        this.errorMsg = errorMsg;
    }

    public BizException(ResultCode res) {
        super(res.getMsg());
        this.res = res;
        this.errorMsg = res.getMsg();
    }

    public BizException(ResultCode res, String errorMsg) {
        super(errorMsg);
        this.res = res;
        this.errorMsg = errorMsg;
    }

}
